//
//  BannerListCell.swift
//  HelloSwift
//
//  Created by alankong on 2016/11/18.
//  Copyright © 2016年 tuotiansudai. All rights reserved.
//

import UIKit

class BannerListCell: UITableViewCell {
    var imgView: UIImageView = UIImageView()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style:style, reuseIdentifier:reuseIdentifier)
        
        setupViews()
    }
    
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupViews() {
        self.imgView = UIImageView(frame: self.bounds)
        self.contentView.addSubview(self.imgView)
        self.imgView.contentMode = UIViewContentMode.scaleAspectFit
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        self.imgView.frame = self.bounds;
        self.imgView.height -= 8;
        self.imgView.center = CGPoint(x: self.width/2, y: self.height/2)
    }
    
    func setBannerVO(bannerVO VO:BannerVO) {
        let url:URL = URL(string: VO.picture!)!
        self.imgView.setImageWith(url)
        self.setNeedsLayout()
    }

}
